﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DacSanMienTayOBJ;
using System.Text;

public partial class Proccess_UpdateAllFieldGroupProduct : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        UpdateProductGroup();
    }
    private void UpdateProductGroup()
    {
        try
        {
            int groupID = int.Parse(Request["groupID"]);
            string groupName = Request["groupName"];
            string keyword = Request["keyword"];
            int vt = int.Parse(Request["vt"]);
            int visible = int.Parse(Request["visible"]);
            GroupProduct group = new GroupProduct();
            group.GroupName = groupName;
            group.MetaKeyword = keyword;
            StringBuilder builder = new StringBuilder();

            bool rs = GroupProductBusiness.UpdateGroupProduct(groupID, group, ConnectionType.AdminConnection);
            if (rs)
            {
                string status = "";
                if (visible == 1)
                {
                    status = "Active";
                }
                else
                {
                    status = "Inactive";
                }
                builder.Append("<td><label id=\"lbGroupID" + vt + "\" title=\"" + groupID + "\">" + groupID + "</label></td>");
                builder.Append("<td><input type=\"text\" style=\"width:350px\" value=\"" + groupName + "\" id=\"txtName" + vt + "\" /> </td>");
                builder.Append("   <td><textarea type=\"text\" style=\"width:350px\" id=\"txtKeywordUpdate"+vt+"\" cols=\"1\" rows=\"2\" >"+keyword+"</textarea> </td>");
                builder.Append("<td>" + status + "</td>");
                builder.Append("<td><input type=\"button\" value=\"Cập nhật\" onclick=\"UpdateGroupProduct('" + groupID + "','" + vt + "','" + visible + "')\" /> </td>");
                builder.Append("<td>");
                if (visible == 1)
                {
                    builder.Append("<input type=\"button\" value=\"Lock\" onclick=\"LockAndUnclockGroupProduct('" + groupID + "','" + vt + "','lock','" + visible + "')\" />");
                }
                else
                {

                    builder.Append("<input type=\"button\" value=\"UnLock\" onclick=\"LockAndUnclockGroupProduct('" + groupID + "','" + vt + "','unlock','" + visible + "')\" />");

                }
                builder.Append("</td>");
                Response.Write(builder);
            }
            else
            {
                Response.Write("errorupdategroup");
            }
            Response.End();
        }
        catch
        {

        }
    }
}